package com.huilian.tool.common.utils;

import java.util.Arrays;

/**
 * @authou 少凡
 * @Date 2019-04-12 16:23
 */
public class CheckUtil {

    public static boolean checkSignature(String signature, String timestamp, String nonce, String token) {

        String[] paramArr = new String[]{token, timestamp, nonce};

        //排序
        Arrays.sort(paramArr);

        //拼接成字符串，进行sha1加密
        StringBuilder content = new StringBuilder();
        for (String aParamArr : paramArr) {
            content.append(aParamArr);
        }

        String temp = SHA1.encode(content.toString());
        // 3.与signature参数进行对比，并返回对比结果
        return temp.equals(signature);
    }
}
